package com.net.framework.help.widget.tencentx5;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.google.zxing.Result;
import com.net.framework.help.R;
import com.net.framework.help.dialog.AlertDialog;
import com.net.framework.help.dialog.CustomSimpleDialog;
import com.net.framework.help.dialog.ImageDiscernDialog;
import com.net.framework.help.httprequest.OkHttp3Utils;
import com.net.framework.help.utils.DateUtil;
import com.net.framework.help.utils.LogUtils;
import com.net.framework.help.utils.SaveImageUitle;
import com.net.framework.help.utils.StringUtil;
import com.net.framework.help.utils.UIUtils;
import com.net.framework.help.zxing.DecodeImage;
import com.net.framework.help.zxing.QrcodeResultJump;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.tencent.smtt.export.external.interfaces.IX5WebChromeClient.CustomViewCallback;
import com.tencent.smtt.export.external.interfaces.JsPromptResult;
import com.tencent.smtt.export.external.interfaces.JsResult;
import com.tencent.smtt.export.external.interfaces.WebResourceResponse;
import com.tencent.smtt.sdk.ValueCallback;
import com.tencent.smtt.sdk.WebChromeClient;
import com.tencent.smtt.sdk.WebSettings;
import com.tencent.smtt.sdk.WebSettings.LayoutAlgorithm;
import com.tencent.smtt.sdk.WebView;
import com.tencent.smtt.sdk.WebViewClient;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class X5WebView extends WebView {
    public static final int FILE_CHOOSER = 0;
    private static boolean isSmallWebViewDisplayed = false;
    private Map<String, Object> mJsBridges;
    private TextView toolbarTitle;
    private String titleName;
    private Context context;
    private ProgressBar progressBar;
    private SwipeRefreshLayout swipeRefreshLayout;
    private boolean isEnabledPullDown = true;
    private LoadWebViewFinished loadWebViewFinished;
    private OnClickUrlListener onClickUrlListener;
    private OnScrollChangedCallback onScrollChangedCallback;
    //    private LongClickCallBack longClickCallBack;
    private String longClickUrl;//长按图片Url地址

    private boolean isShowTitle;//是否显示title，默认不显示

    public X5WebView(Context context, TextView toolbarTitle, ProgressBar progressBar) {//, ProgressBar progressBar
        super(context);
        this.toolbarTitle = toolbarTitle;
        this.progressBar = progressBar;
        init(context);
    }


    public X5WebView(Context context, LoadWebViewFinished loadWebViewFinished, TextView toolbarTitle, ProgressBar progressBar, String titleName) {//
        this(context, toolbarTitle, progressBar);
        this.titleName = titleName;
        this.loadWebViewFinished = loadWebViewFinished;
    }

    @SuppressLint("SetJavaScriptEnabled")
    public X5WebView(Context arg0, AttributeSet arg1) {
        super(arg0, arg1);
        init(arg0);
    }

    public X5WebView(Context context) {
        super(context);
        init(context);
    }

    //    public LongClickCallBack getLongClickCallBack() {
    //        return longClickCallBack;
    //    }
    //
    //    public void setLongClickCallBack(LongClickCallBack longClickCallBack) {
    //        this.longClickCallBack = longClickCallBack;
    //    }

    public void setShowTitle(boolean showTitle) {
        isShowTitle = showTitle;
    }

    public void setOnScrollChangedCallback(OnScrollChangedCallback onScrollChangedCallback) {
        this.onScrollChangedCallback = onScrollChangedCallback;
    }

    @Override
    public boolean onLongClick(View view) {
        LogUtils.println("进入长按的事件========");
        // 长按事件监听（注意：需要实现LongClickCallBack接口并传入对象）
        final WebView.HitTestResult htr = getHitTestResult();//获取所点击的内容
        if (htr.getType() == android.webkit.WebView.HitTestResult.IMAGE_TYPE) {//判断被点击的类型为图片
            getImageDiscernDialog();
            longClickUrl = htr.getExtra();
            // 获取到图片地址后做相应的处理
            MyAsyncTask mTask = new MyAsyncTask();
            mTask.execute(longClickUrl);
        }
        return false;
    }

    public void setPullDownRefresh(boolean isEnabledPullDown) {
        LogUtils.println("是否允许下拉刷新===" + isEnabledPullDown);
        if (this.isEnabledPullDown == isEnabledPullDown) {
            return;
        }
        this.isEnabledPullDown = isEnabledPullDown;
        swipeRefreshLayout.setEnabled(isEnabledPullDown);
    }

    public void setOnClickUrlListener(OnClickUrlListener onClickUrlListener) {
        this.onClickUrlListener = onClickUrlListener;
    }

    public void setSwipeRefreshLayout(SwipeRefreshLayout swipeRefreshLayout) {
        this.swipeRefreshLayout = swipeRefreshLayout;
    }

    private void init(Context context) {
        this.context = context;
        if (null != progressBar) {
            progressBar.setProgressDrawable(UIUtils.getDrawable(R.drawable.progress_bar_states));
        }
        //        webProgressDialogHandler = new WebProgressDialogHandler(context, true);

        this.setWebViewClientExtension(new X5WebViewEventHandler(this));// 配置X5webview的事件处理
        this.setWebViewClient(client);
        this.setWebChromeClient(chromeClient);
        initWebViewSettings();
        this.getView().setClickable(true);
        this.getView().setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                return false;
            }
        });
        this.setOnLongClickListener(this);
    }

    private void setTitle(String title) {
        if (StringUtil.isBlank(title)) {
            title = "";
        } else {
            title = StringUtil.isUrl(title) || title.contains(".com") ? "" : title;
        }
        LogUtils.println("标题====" + title + "**");
        if (null != toolbarTitle && isShowTitle) {
            if (StringUtil.isBlank(title)) {
                if (StringUtil.isBlank(titleName)) {
                    toolbarTitle.setText("");
                } else {
                    toolbarTitle.setText(titleName);
                }
            } else {
                toolbarTitle.setText(title);
            }

        }
    }

    private WebViewClient client = new WebViewClient() {
        /**
         * 防止加载网页时调起系统浏览器
         */
        public boolean shouldOverrideUrlLoading(final WebView view, final String url) {
            //            WebView.HitTestResult hitTestResult = view.getHitTestResult();
            if (null == onClickUrlListener) {
                return true;
            }
            if (StringUtil.isBlank(url)) {
                return true;
            }

            if (url.contains(".apk")) {
                Intent viewIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                context.startActivity(viewIntent);
                return true;
            }
            //解决重定向问题
            //            new Thread(new Runnable() {
            //                public void run() {
            //                    try {
            //                        URL Url = new URL(url);
            //                        try {
            //                            HttpURLConnection conn = (HttpURLConnection) Url.openConnection();
            //                            int code = conn.getResponseCode();
            //                            LogUtils.println("code===重新向地址===" + code);
            //                            if (code == 301) {
            //                                LogUtils.println("重新向地址");
            //                            } else {
            //
            //                            }
            //                        } catch (IOException e) {
            //                            e.printStackTrace();
            //                        }
            //                    } catch (MalformedURLException e) {
            //                        e.printStackTrace();
            //                    }
            //                }
            //            }).start();
            onClickUrlListener.onUrlLoading(view, url);
            return true;
        }

        public void onReceivedHttpAuthRequest(WebView webview, com.tencent.smtt.export.external.interfaces.HttpAuthHandler httpAuthHandlerhost, String host, String realm) {
        }

        /**
         * 页面加载过程中，加载资源回调的方法
         *
         * @param view
         * @param url
         */
        @Override
        public void onLoadResource(WebView view, String url) {
            super.onLoadResource(view, url);
        }

        /**
         * 页面加载完成回调的方法
         *
         * @param view
         * @param url
         */
        @Override
        public void onPageFinished(WebView view, String url) {
            if (null != loadWebViewFinished) {
                loadWebViewFinished.onWebViewFinished(url);
            }
            if (null != progressBar) {
                // 加载完成隐藏进度界面,显示WebView内容
                progressBar.setVisibility(View.GONE);
            }
            //            dismissProgressDialog();

            String title = view.getTitle();
            setTitle(title);
            super.onPageFinished(view, url);
        }

        /**
         * 页面开始加载调用的方法
         *
         * @param view
         * @param url
         * @param favicon
         */
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            if (null != onClickUrlListener) {
                onClickUrlListener.onStartLoadUrl(url);
            }
            //            showProgressDialog();
            super.onPageStarted(view, url, favicon);
        }

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            LogUtils.println("加载失败errorCode:-----------" + errorCode);
            super.onReceivedError(view, errorCode, description, failingUrl);
        }

        @Override
        public WebResourceResponse shouldInterceptRequest(WebView webView, String s) {
            return super.shouldInterceptRequest(webView, s);
        }
    };

    private WebChromeClient chromeClient = new WebChromeClient() {
        View myVideoView;
        View myNormalView;
        CustomViewCallback callback;

        /**
         * 全屏播放配置
         */
        @Override
        public void onShowCustomView(View view, CustomViewCallback customViewCallback) {
            FrameLayout normalView = X5WebView.this;
            ViewGroup viewGroup = (ViewGroup) normalView.getParent();
            viewGroup.removeView(normalView);
            viewGroup.addView(view);
            myVideoView = view;
            myNormalView = normalView;
            callback = customViewCallback;
        }

        @Override
        public void onHideCustomView() {
            if (callback != null) {
                callback.onCustomViewHidden();
                callback = null;
            }
            if (myVideoView != null) {
                ViewGroup viewGroup = (ViewGroup) myVideoView.getParent();
                viewGroup.removeView(myVideoView);
                viewGroup.addView(myNormalView);
            }
        }

        @Override
        public void openFileChooser(ValueCallback<Uri> uploadFile, String acceptType, String captureType) {
            Intent i = new Intent(Intent.ACTION_GET_CONTENT);
            i.addCategory(Intent.CATEGORY_OPENABLE);
            i.setType("*/*");
            ((Activity) (X5WebView.this.getContext())).startActivityForResult(Intent.createChooser(i, "choose files"), X5WebView.FILE_CHOOSER);
            super.openFileChooser(uploadFile, acceptType, captureType);
        }

        /**
         * webview 的窗口转移
         */
        @Override
        public boolean onCreateWindow(WebView arg0, boolean arg1, boolean arg2, Message msg) {
            // TODO Auto-generated method stub
            if (X5WebView.isSmallWebViewDisplayed == true) {
                WebViewTransport webViewTransport = (WebViewTransport) msg.obj;
                WebView webView = new WebView(X5WebView.this.getContext()) {
                    protected void onDraw(Canvas canvas) {
                        super.onDraw(canvas);
                        Paint paint = new Paint();
                        paint.setColor(Color.GREEN);
                        paint.setTextSize(15);
                        canvas.drawText("新建窗口", 10, 10, paint);
                    }
                };
                webView.setWebViewClient(new WebViewClient() {
                    public boolean shouldOverrideUrlLoading(WebView arg0, String arg1) {
                        arg0.loadUrl(arg1);
                        return true;
                    }
                });
                LayoutParams lp = new LayoutParams(400, 600);
                lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL;
                X5WebView.this.addView(webView, lp);
                webViewTransport.setWebView(webView);
                msg.sendToTarget();
            }
            return true;
        }

        @Override
        public void onReceivedTitle(WebView web, final String title) {
            super.onReceivedTitle(web, title);
            setTitle(title);
        }

        /**
         * 网页加载进度回调
         *
         * @param view
         * @param newProgress
         */
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            if (null == progressBar) {
                return;
            }
            // 设置进行进度
            ((Activity) context).getWindow().setFeatureInt(Window.FEATURE_PROGRESS, newProgress * 100);
            progressBar.setVisibility(View.VISIBLE);
            progressBar.setProgress(newProgress);
            progressBar.postInvalidate(); // 刷新UI
            if (newProgress == 100) {
                progressBar.setVisibility(View.GONE);
            }
        }

        /**
         * 对应js 的通知弹框,可以用来实现js 和 android之间的通信
         */
        @Override
        public boolean onJsPrompt(WebView arg0, String arg1, String arg2, String arg3, JsPromptResult arg4) {
            // 在这里可以判定js传过来的数据，用于调起android native 方法
            if (X5WebView.this.isMsgPrompt(arg1)) {
                if (X5WebView.this.onJsPrompt(arg2, arg3)) {
                    return true;
                } else {
                    return false;
                }
            }
            return super.onJsPrompt(arg0, arg1, arg2, arg3, arg4);
        }

        @Override
        public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
            getInitCustomSimpleDialog().getSimpleSingleBtn(null, R.string.btn_close_text, message, null);
            result.confirm();
            return true;
        }

        @Override
        public boolean onJsConfirm(WebView arg0, String url, String message, final JsResult result) {
            AlertDialog alertDialog = new AlertDialog(context).builder();
            alertDialog.setTitle(null).setMsg(message).setPositiveButton(UIUtils.getString(R.string.btn_confirm_text), new OnClickListener() {
                @Override
                public void onClick(View v) {
                    result.confirm();
                }
            }).setNegativeButton(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    result.cancel();
                }
            }).dismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    result.cancel();
                }
            });
            alertDialog.show();
            return true;
        }
    };

    private CustomSimpleDialog customSimpleDialog;

    private CustomSimpleDialog getInitCustomSimpleDialog() {
        if (null == customSimpleDialog) {
            customSimpleDialog = new CustomSimpleDialog(context);
        }
        return customSimpleDialog;
    }

    private void initWebViewSettings() {
        this.setInitialScale(100);
        WebSettings webSetting = this.getSettings();
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//            webSetting.setMixedContentMode(android.webkit.WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
//        }
        webSetting.setJavaScriptEnabled(true);
        webSetting.setJavaScriptCanOpenWindowsAutomatically(true);
        webSetting.setAllowFileAccess(true);
        webSetting.setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS);

        //缩放
        webSetting.setSupportZoom(true);
        webSetting.setBuiltInZoomControls(true);
        webSetting.setDisplayZoomControls(false);
        webSetting.setUseWideViewPort(true);
        webSetting.setSupportMultipleWindows(true);
        //提高网页加载速度，暂时阻塞图片加载，然后网页加载好了，在进行加载图片
        //        webSetting.setBlockNetworkImage(true);
        //缓存策略
        webSetting.setAppCacheEnabled(true);
        webSetting.setDomStorageEnabled(true);
        webSetting.setGeolocationEnabled(true);
        webSetting.setAppCacheMaxSize(Long.MAX_VALUE);
        webSetting.setPluginState(WebSettings.PluginState.ON_DEMAND);
        webSetting.setRenderPriority(WebSettings.RenderPriority.HIGH);
        webSetting.setCacheMode(WebSettings.LOAD_DEFAULT);
        String e_json = "{\"clientTag\": \"Android_App\",\"token\": \"" + (StringUtil.isBlank(OkHttp3Utils.userToken) ? "" : OkHttp3Utils.userToken) + "\"}";
        webSetting.setUserAgentString(webSetting.getUserAgentString() + " extras/" + e_json);
        LogUtils.println("WEB的UserAgent===" + webSetting.getUserAgentString());
    }

    //    @Override
    //    protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
    //        boolean ret = super.drawChild(canvas, child, drawingTime);
    //        canvas.save();
    //        Paint paint = new Paint();
    //        paint.setColor(0x7fff0000);
    //        paint.setTextSize(24.f);
    //        paint.setAntiAlias(true);
    //        if (getX5WebViewExtension() != null) {
    //            canvas.drawText(this.getContext().getPackageName() + "-pid:" + android.os.Process.myPid(), 10, 50, paint);
    //            canvas.drawText("X5  Core:" + QbSdk.getTbsVersion(this.getContext()), 10, 100, paint);
    //        } else {
    //            canvas.drawText(this.getContext().getPackageName() + "-pid:" + android.os.Process.myPid(), 10, 50, paint);
    //            canvas.drawText("Sys Core", 10, 100, paint);
    //        }
    //        canvas.drawText(Build.MANUFACTURER, 10, 150, paint);
    //        canvas.drawText(Build.MODEL, 10, 200, paint);
    //        canvas.restore();
    //        return ret;
    //    }


    public static void setSmallWebViewEnabled(boolean enabled) {
        isSmallWebViewDisplayed = enabled;
    }

    public void addJavascriptBridge(SecurityJsBridgeBundle jsBridgeBundle) {
        if (this.mJsBridges == null) {
            this.mJsBridges = new HashMap<String, Object>(5);
        }
        if (jsBridgeBundle != null) {
            String tag = SecurityJsBridgeBundle.BLOCK + jsBridgeBundle.getJsBlockName() + "-"
                    + SecurityJsBridgeBundle.METHOD + jsBridgeBundle.getMethodName();
            this.mJsBridges.put(tag, jsBridgeBundle);
        }
    }

    /**
     * 当webchromeClient收到 web的prompt请求后进行拦截判断，用于调起本地android方法
     *
     * @param methodName 方法名称
     * @param blockName  区块名称
     * @return true ：调用成功 ； false ：调用失败
     */
    private boolean onJsPrompt(String methodName, String blockName) {
        String tag = SecurityJsBridgeBundle.BLOCK + blockName + "-" + SecurityJsBridgeBundle.METHOD + methodName;
        if (this.mJsBridges != null && this.mJsBridges.containsKey(tag)) {
            ((SecurityJsBridgeBundle) this.mJsBridges.get(tag)).onCallMethod();
            return true;
        } else {
            return false;
        }
    }

    /**
     * 判定当前的prompt消息是否为用于调用native方法的消息
     *
     * @param msg 消息名称
     * @return true 属于prompt消息方法的调用
     */
    private boolean isMsgPrompt(String msg) {
        if (msg != null && msg.startsWith(SecurityJsBridgeBundle.PROMPT_START_OFFSET)) {
            return true;
        } else {
            return false;
        }
    }

    // TBS: Do not use @Override to avoid false calls
    public boolean tbs_dispatchTouchEvent(MotionEvent ev, View view) {
        boolean r = super.super_dispatchTouchEvent(ev);
        return r;
    }

    // TBS: Do not use @Override to avoid false calls
    public boolean tbs_onInterceptTouchEvent(MotionEvent ev, View view) {
        boolean r = super.super_onInterceptTouchEvent(ev);
        return r;
    }

    protected void tbs_onScrollChanged(int l, int t, int oldl, int oldt, View view) {
        super_onScrollChanged(l, t, oldl, oldt);
        if (null != onScrollChangedCallback) {
            onScrollChangedCallback.onScroll(l, t);
        }
    }

    protected void tbs_onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY, View view) {
        //        if (clampedY) {
        //            this.isClampedY = true;
        //        } else {
        //            this.isClampedY = false;
        //        }
        if (null != swipeRefreshLayout) {
            if (scrollY == 0 && isEnabledPullDown) {
                swipeRefreshLayout.setEnabled(true);
            } else {
                swipeRefreshLayout.setEnabled(false);
            }
        }
        super_onOverScrolled(scrollX, scrollY, clampedX, clampedY);
    }

    protected void tbs_computeScroll(View view) {
        super_computeScroll();
    }

    protected boolean tbs_overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent, View view) {
        //        if (this.isClampedY) {
        //            this.layout(this.getLeft(), this.getTop() + (-deltaY) / 2, this.getRight(), this.getBottom() + (-deltaY) / 2);
        ////            this.layout(this.getLeft(), this.getTop() + deltaY, this.getRight(), this.getBottom() + deltaY);
        //        }
        return super_overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX, scrollRangeY, maxOverScrollX, maxOverScrollY, isTouchEvent);
    }


    protected boolean tbs_onTouchEvent(MotionEvent event, View view) {
        if (event.getAction() == MotionEvent.ACTION_UP) {
            //            this.isClampedY = false;
            this.layout(this.getLeft(), 0, this.getRight(), this.getBottom());
        }
        return super_onTouchEvent(event);
    }

    public interface OnScrollChangedCallback {
        void onScroll(int l, int t);
    }

    public interface LoadWebViewFinished {
        void onWebViewFinished(String url);
    }

    public interface OnClickUrlListener {
        void onUrlLoading(WebView view, String url);

        void onStartLoadUrl(String url);
    }

    //    /**
    //     * 长按事件回调接口，传递图片地址
    //     *
    //     * @author LinZhang
    //     */
    //    public interface LongClickCallBack {
    //        /**
    //         * 用于传递图片地址
    //         */
    //        void onLongClickCallBack(String imgUrl);
    //    }


    /*-------------------------识别二维码图片---------------------------------------------------------*/
    private boolean isQR;//判断是否为二维码
    private Result result;//二维码解析结果
    private Bitmap imageBitmap;
    private ImageDiscernDialog imageDiscernDialog;

    private Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            if (msg.what == 0) {
                if (isQR) {
                    imageDiscernDialog.showDiscernQrcodeView(true);
                }
            }
        }
    };

    public class MyAsyncTask extends AsyncTask<String, Void, String> {
        @Override
        protected void onPostExecute(String s) {
            super.onPostExecute(s);
            if (isQR) {
                handler.sendEmptyMessage(0);
            }
        }

        @Override
        protected String doInBackground(String... params) {
            decodeImage(params[0]);
            return null;
        }
    }

    /**
     * 判断是否为二维码
     * param url 图片地址
     * return Bitmap
     */
    private boolean decodeImage(String sUrl) {
        result = DecodeImage.handleQRCodeFormBitmap(getImageBitmap(sUrl));
        if (result == null) {
            isQR = false;
        } else {
            isQR = true;
        }
        return isQR;
    }

    private Bitmap getImageBitmap(String sUrl) {
        imageBitmap = ImageLoader.getInstance().loadImageSync(sUrl);
        return imageBitmap;
    }

    /**
     * 弹出对话框
     */
    private void getImageDiscernDialog() {
        if (null == imageDiscernDialog) {
            imageDiscernDialog = new ImageDiscernDialog(context, new ImageDiscernDialog.ImageDiscernCallback() {
                @Override
                public void onSendImage() {

                }

                @Override
                public void onSaveImage() {
                    //保存到本地相册
                    SaveImageUitle.saveImage(context, DateUtil.getFormatDateTime(new Date(), "yyyyMMddHHmmss"), imageBitmap);
                }

                @Override
                public void onDiscernQrcode() {
                    LogUtils.println("识别的二维码内容=====" + result.toString());
                    getQrcodeResultJump().jump(context, result.toString());
                }
            });
        }
        imageDiscernDialog.getShowDialog();
    }

    /*------------------二维码跳转逻辑-------------------------------*/
    private QrcodeResultJump qrcodeResultJump;

    private QrcodeResultJump getQrcodeResultJump() {
        if (null == qrcodeResultJump) {
            qrcodeResultJump = new QrcodeResultJump();
        }
        return qrcodeResultJump;
    }

    /*---------------------loading弹窗----------------------------------*/
    //    private WebProgressDialogHandler webProgressDialogHandler;
    //
    //    private void showProgressDialog() {
    //        if (webProgressDialogHandler != null) {
    //            webProgressDialogHandler.obtainMessage(WebProgressDialogHandler.SHOW_PROGRESS_DIALOG).sendToTarget();
    //        }
    //    }
    //
    //    private void dismissProgressDialog() {
    //        if (webProgressDialogHandler != null) {
    //            webProgressDialogHandler.obtainMessage(WebProgressDialogHandler.DISMISS_PROGRESS_DIALOG).sendToTarget();
    //            webProgressDialogHandler = null;
    //        }
    //    }
}
